import ApiComm from '../ApiComm'
import { doDownLoadFile } from '@/libs/tools'

export default {
  create: (info) => {
    return ApiComm.$http.put('/server/workflow/definition', info)
  },
  delete: (ids) => {
    return ApiComm.$http.delete('/server/workflow/definition', {
      data: ids
    })
  },
  update: (info) => {
    return ApiComm.$http.patch('/server/workflow/definition', info)
  },
  query: (query) => {
    return ApiComm.$http.post('/server/workflow/definition', query)
  },
  publish: (id) => {
    return ApiComm.$http.post('/server/workflow/definition/publish/' + id)
  },
  unPublish: (id) => {
    return ApiComm.$http.delete('/server/workflow/definition/publish/' + id)
  },
  active: (id) => {
    return ApiComm.$http.post('/server/workflow/definition/active/' + id)
  },
  unActive: (id) => {
    return ApiComm.$http.delete('/server/workflow/definition/active/' + id)
  },
  import: (info) => {
    return ApiComm.$http.post('/server/workflow/definition/import', info)
  },
  downLoadFile: (id) => {
    doDownLoadFile(
      ApiComm.$store.appInfo.baseURL + '/server/workflow/definition/export/' + id
    )
  }
}
